-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PEP 695] Support recursive type aliases #17268
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, otherwise LGTM
mypy/semanal.py
Outdated
# for a TypeInfo _in place_ if there are nested placeholders. | ||
existing.node.target = res | ||
existing.node.alias_tvars = alias_tvars | ||
# existing.node.no_args = no_args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out? IIRC this is to support prehistoric edge case where you have
A = B
B = C
C = D
and D
is generic class. In such cases A[int]
is allowed and equivalent to D[int]
. If this works without this line then just delete it. (Or maybe this use case is explicitly prohibited with the new syntax, then I guess this is not needed either). For context, IIRC this was initially allowed for aliases like List = list
+ forward references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not supported by the new syntax. Type parameters need to be explicit. I will delete the line.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
The implementation follows the approach used for old-style type aliases.
Work on #15238.